-
Notifications
You must be signed in to change notification settings - Fork 223
Test: Secondary bidder #4328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: secondary-bidders
Are you sure you want to change the base?
Test: Secondary bidder #4328
Conversation
osulzhenko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure the test waits for all primary bidders to respond. We need to ensure the code waits for the last one, not the first. Please add a test case with two primary bidders and one secondary bidder to the spec
| OPENX("openx"), | ||
| AMX("amx"), | ||
| AMX_UPPER_CASE("AMX"), | ||
| OPENX_ALIAS("openxalias"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not regular alias?
src/test/groovy/org/prebid/server/functional/tests/SecondaryBidderSpec.groovy
Show resolved
Hide resolved
| protected static final Bidder openXBidder = new Bidder(networkServiceContainer, "/openx-auction") | ||
| protected static final Bidder openXAliasBidder = new Bidder(networkServiceContainer, "/openx-alias-auction") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
| protected static final Bidder openXAliasBidder = new Bidder(networkServiceContainer, "/openx-alias-auction") | ||
|
|
||
| @Shared | ||
| PrebidServerService pbsServiceWithOpenXAndIXBidder = pbsServiceFactory.getService(OPENX_CONFIG + OPENX_ALIAS_CONFIG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pbsServiceWithOpenXBidder
| assert !bidResponse.ext.seatnonbid | ||
| } | ||
|
|
||
| def "PBS should emit a warning when null in secondary bidders config"() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't?
| openXAliasBidder.reset() | ||
| } | ||
|
|
||
| def "PBS shouldn't wait on secondary bidder when alias bidder respond with dilay"() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty similar to def "PBS shouldn't treated alias bidder as secondary when root bidder code in secondary"
| accountDao.save(account) | ||
|
|
||
| and: "Set up openx bidder response with delay" | ||
| openXBidder.setResponseWithDilay(5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delay also should be constant
| : HttpResponse.notFoundResponse()} | ||
| } | ||
|
|
||
| void setResponseWithDilay(Integer dilayTimeout = 5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
| openXBidder.setResponse() | ||
| openXAliasBidder.setResponse() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need to set response at end of spec
| "adapters.openx.enabled" : "true", | ||
| "adapters.openx.endpoint": "$networkServiceContainer.rootUri/openx-auction".toString()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace openx with ${OPENX.value}
| private static final Bidder openXBidder = new Bidder(networkServiceContainer, "/openx-auction") | ||
| private static final Bidder genericAliasBidder = new Bidder(networkServiceContainer, "/generic-alias-auction") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use openx-auction and generic-alias-auction in several places. Please make them constants
|
|
||
| cleanup: "Reset mock" | ||
| openXBidder.reset() | ||
| genericAliasBidder.reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls make cleanup as separate method
@Override
def cleanup() {
openXBidder.reset()
genericAliasBidder.reset()
}
| def "PBS shouldn't emit a warning when empty secondary bidders config"() { | ||
| given: "Default basic BidRequest with generic bidder" | ||
| def bidRequest = BidRequest.defaultBidRequest.tap { | ||
| enabledReturnAllBidStatus() | ||
| } | ||
|
|
||
| and: "Account in the DB" | ||
| def accountConfig = AccountConfig.defaultAccountConfig.tap { | ||
| it.auction = new AccountAuctionConfig(secondaryBidders: [null]) | ||
| } | ||
| def account = new Account(uuid: bidRequest.accountId, config: accountConfig) | ||
| accountDao.save(account) | ||
|
|
||
| when: "PBS processes auction request" | ||
| def bidResponse = pbsServiceWithOpenXBidder.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "PBs should processed bidder request" | ||
| assert bidder.getBidderRequest(bidRequest.id) | ||
|
|
||
| and: "PBS shouldn't contain errors, warnings and seat non bid" | ||
| assert !bidResponse.ext?.warnings | ||
| assert !bidResponse.ext?.errors | ||
| assert !bidResponse.ext?.seatnonbid | ||
| } | ||
|
|
||
| def "PBS shouldn't emit a warning when invalid bidder in secondary bidders config"() { | ||
| given: "Default basic BidRequest with generic bidder" | ||
| def bidRequest = BidRequest.defaultBidRequest.tap { | ||
| enabledReturnAllBidStatus() | ||
| } | ||
|
|
||
| and: "Account in the DB" | ||
| def accountConfig = AccountConfig.defaultAccountConfig.tap { | ||
| it.auction = new AccountAuctionConfig(secondaryBidders: [UNKNOWN]) | ||
| } | ||
| def account = new Account(uuid: bidRequest.accountId, config: accountConfig) | ||
| accountDao.save(account) | ||
|
|
||
| when: "PBS processes auction request" | ||
| def bidResponse = pbsServiceWithOpenXBidder.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "PBs should processed bidder request" | ||
| def bidderRequests = bidder.getBidderRequests(bidRequest.id) | ||
| assert bidderRequests.size() == 1 | ||
|
|
||
| and: "PBS shouldn't contain errors, warnings and seat non bid" | ||
| assert !bidResponse.ext?.warnings | ||
| assert !bidResponse.ext?.errors | ||
| assert !bidResponse.ext?.seatnonbid | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be combined with a where block to handle invalid secondary bidders
| def bidRequest = BidRequest.defaultBidRequest.tap { | ||
| it.imp[0].ext.prebid.bidder.openx = Openx.defaultOpenx | ||
| enabledReturnAllBidStatus() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add private method:
private void getEnrichedBidRequest(List<BidderName> bidderNames) {
BidRequest.defaultBidRequest.tap {
if (bidderNames.contains(OPENX)) {
it.imp[0]?.ext?.prebid?.bidder?.openx = Openx.defaultOpenx
}
if (bidderNames.contains(ALIAS)) {
it.imp[0]?.ext?.prebid?.bidder?.alias = new Generic()
}
enabledReturnAllBidStatus()
}
}
|
|
||
| and: "Set up openx bidder response with delay" | ||
| openXBidder.reset() | ||
| openXBidder.setResponseWithDelay(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic number
src/test/groovy/org/prebid/server/functional/tests/SecondaryBidderSpec.groovy
Show resolved
Hide resolved
| assert openXAliasBidderRequests.size() == 1 | ||
|
|
||
| and: "PBs repose shouldn't contain response body from openX bidder" | ||
| assert !bidResponse?.ext?.debug?.httpcalls[OPENX]?.responseBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual
🔧 Type of changes
✨ What's the context?
What's the context for the changes?
🧠 Rationale behind the change
Why did you choose to make these changes? Were there any trade-offs you had to consider?
🔎 New Bid Adapter Checklist
🧪 Test plan
How do you know the changes are safe to ship to production?
🏎 Quality check